export default {
	// 获取页面数据
	getTableData() {
		var params = {
			id: this.id,
			language: this.$store.getters.getLanguage,
			
		}

		this.axiosGets("MainIndex/audioShow", params, function(res) {
			console.log(res);
			if (res.data.code === 0) {
				this.msgSuccess(res.data.message)
				this.form = res.data.data[0]
				// this.imageUrl = this.imgURL + this.form.files.url + '/' + this.form.files.name
				this.audioUrl = this.imgURL + this.form.file.url + '/' + this.form.file.name
				this.upImg.imageUrl = this.imgURL + this.form.files.url + '/' + this.form.files.name;
				let arr = [{
					name: this.form.file.name,
					url: this.imgURL + this.form.file.url + '/' + this.form.file.name
				}];
				this.fileList = arr.map(item => item);

				console.log(this.fileList);
			} else {
				this.msgError(res.data.message)
			}

		})
	},


	// submitUpload() {
	// 	this.$refs.img.submit();
	// 	this.$refs.audio.submit();

	// },


	//编辑
	edit() {
		// console.log(this.$refs)
		this.upImg = this.$refs.UploadImg.upImg;
		// let params = this.form;
		
		const params = new FormData();
		
		// let params = {}
		console.log(this.form.audio_id)
		// params.append('a',1);
		// formData.append('audio_id',this.form.audio_id);
		if(this.form.audio) {
			// params.audio = this.form.audio;
		params.append('audio',this.form.audio );
		}
		if(this.upImg.file) {
			// params.file = this.upImg.file;
		params.append('file',this.upImg.file );
		}
		// params.language = 0;
		params.append('language',this.$store.getters.getLanguage);
		// setTimeout(() => {
		// console.log(params.get('language'))
		// console.log(formData.get('a'))
		// formData.get('a');
		// },3000)
		
		this.axiosPostFile('MainIndex/audio', params, res => {
			if (res.data.code === 0) {
				this.msgSuccess(res.data.message)
			}
		})
	},

	//图片上传
	// handleAvatarSuccess(file) {
	// 	console.log(file);
	// 	this.form.files = file;
	// 	let reader = new FileReader();
	// 	reader.readAsDataURL(file)
	// 	let that = this;
	// 	reader.onload = function (evt) {
	// 		console.log(evt);
	// 		that.imageUrl = evt.target.result;
	// 	// console.log(this.imageUrl);
	// 	}
	// 	return false;
	// },
	handleAvatarSuccess1(file) {
		console.log(file);
		this.form.audio = file;
		this.fileList = [{file:file,name:file.name}]
		this.form.language = this.id;
		return false;
	},
}
